\name{treeMI}

\alias{treeMI}

\title{Perform chained multiple imputation using trees}

\description{
  \code{treeMI} creates imputed datasets using 
  trees to predict the missing data, under a chained imputation strategy.
}

\arguments{
  \item{thedata}{A matrix of data with missing values coded as \code{NA}.}
  \item{ITER}{The number of imputation iterations.}
  \item{factorvar}{A vector of indicators for which columns of 
  \code{newdata} are factors.}
  \item{starter}{Logical.  If \code{TRUE}, the function produce starting   
 values for the missing items.  Otherwise, they should be supplied.}
  \item{initiate}{A matrix with no missing values.  This will be the 
  starting values if \code{starter=FALSE}.}
  \item{PPDdraw}{Logical.  Should the function return a draw from 
  the posterior predictive distribution of the data columns with at
  least some missingness?}
  \item{mincut}{Positive integer giving the minimum number of observations
  to include in the child nodes for the imputing trees. See \code{tree} 
  package documentation.}
  \item{mindev}{The within-node deviance must be at least this times 
  that of the root node for the node to be split.  See \code{tree} 
  package documentation.}
  \item{startCut}{\code{mincut} value for the initial imputation if
  \code{starter=TRUE}.}
  \item{startDev}{\code{mindev} value for the initial imputation if
  \code{starter=TRUE}.}
}

\value{
  Returns the data matrix with missing values imputed.  If 
  \code{PPDdraw=TRUE}, also returns a draw from 
  the posterior predictive distribution of the data columns with at
  least some missingness.
}

\author{
  Jerome Reiter and Lane Burgette, Department of Statistical Science,
  Duke University.  \email{jerry@stat.duke.edu, lb131@stat.duke.edu}
}

